import React, {FC, useEffect, useState} from "react";
import {Space, Typography} from "antd";
import {AliwangwangOutlined} from "@ant-design/icons";
import styles from "./Logo.module.scss";
import {Link} from "react-router-dom";
import useGetUserInfo from "../hooks/useGetUserInfo";
import {HOME_PATH, MANAGE_LIST_PATH} from "../router";


const {Title} = Typography;

const Logo: FC = () => {

    const {username} = useGetUserInfo();

    const [path,setPath] =useState(HOME_PATH);

    useEffect(()=>{
        setPath(username? MANAGE_LIST_PATH : HOME_PATH);
    },[username])


    return(
        <div className={styles.all}>
           <Link  to={path}>
               <Space>
                   {/*//title相当于h1*/}
                   <Title>
                       <AliwangwangOutlined />
                   </Title>
                   <Title>妖妖问卷</Title>
               </Space>
           </Link>

        </div>
    )
}

export default Logo;